﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
    xmlns:local="clr-namespace:MotionRemix.Demo"
    xmlns:views="clr-namespace:MotionRemix.Demo.Views">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Colors.xaml" />
        <ResourceDictionary Source="Brushes.xaml" />
        <ResourceDictionary Source="Fonts.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <!-- Geometry figures -->
    <GeometryGroup x:Key="MinimizeIconGeometry">
        <Geometry>
            F1 M 0,23 L 24, 23
        </Geometry>
    </GeometryGroup>

    <GeometryGroup x:Key="MaximizeIconGeometry">
        <Geometry>
            F1 M 0,1 L 23, 1
        </Geometry>
        <Geometry>
            F1 M 23,1 L 23, 23
        </Geometry>
        <Geometry>
            F1 M 0,23 L 23, 23
        </Geometry>
        <Geometry>
            F1 M 0,1 L 0, 23
        </Geometry>
    </GeometryGroup>

    <GeometryGroup x:Key="RestoreIconGeometry">
        <Geometry>
            F1 M 0,8 L 18, 8
        </Geometry>
        <Geometry>
            F1 M 18,8 L 18,24
        </Geometry>
        <Geometry>
            F1 M 18,24 L 0, 24
        </Geometry>
        <Geometry>
            F1 M 0, 24 L 0, 8
        </Geometry>

        <Geometry>
            F1 M 6,6 L 6,0
        </Geometry>
        <Geometry>
            F1 M 6,0 L 24, 0
        </Geometry>

        <Geometry>
            F1 M 24,0 L 24,18
        </Geometry>

        <Geometry>
            F1 M 19,18 L 24,18
        </Geometry>
    </GeometryGroup>

    <GeometryGroup x:Key="CloseIconGeometry">
        <Geometry>
            F1 M 1,1 L 23, 23
        </Geometry>
        <Geometry>
            F1 M 1,23 L 23, 1
        </Geometry>
    </GeometryGroup>

    <!-- Styles -->
    <Style 
        x:Key="ChromeButtonStyle" 
        TargetType="{x:Type Button}">
        <Setter 
            Property="Background" 
            Value="{StaticResource MainColorBrush}" />
        <Setter 
            Property="Foreground" 
            Value="{StaticResource DisabledForegroundBrush}" />
        <Setter 
            Property="HorizontalContentAlignment" 
            Value="Center" />
        <Setter 
            Property="VerticalContentAlignment" 
            Value="Center" />
        <Setter 
            Property="Padding" 
            Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid 
                        x:Name="grid" 
                        Background="{TemplateBinding Background}">
                        <ContentPresenter 
                            x:Name="contentPresenter"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            Margin="{TemplateBinding Padding}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                            RecognizesAccessKey="True"
                            Opacity="0.75" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" 
                                 Value="True">
                            <Setter TargetName="contentPresenter" 
                                    Property="Opacity" 
                                    Value="1" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" 
                                 Value="False">
                            <Setter TargetName="contentPresenter" 
                                    Property="Opacity" 
                                    Value=".5" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" 
                                    Value="{StaticResource DisabledForegroundBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style 
        x:Key="ContentTablStyle"
        TargetType="{x:Type TabControl}">
        <Setter Property="Background"  
                Value="{x:Null}" />
        <Setter Property="BorderBrush" 
                Value="{x:Null}" />
        <Setter Property="HorizontalContentAlignment"
                Value="Center"/>
        <Setter Property="VerticalContentAlignment"
                Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid KeyboardNavigation.TabNavigation="Local"
                          SnapsToDevicePixels="true"
                          ClipToBounds="true">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition x:Name="ColumnDefinition0"/>
                            <ColumnDefinition 
                                x:Name="ColumnDefinition1"
                                Width="0"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition 
                                x:Name="RowDefinition0"
                                Height="Auto"/>
                            <RowDefinition 
                                x:Name="RowDefinition1"
                                Height="*"/>
                        </Grid.RowDefinitions>
                        <TabPanel 
                            x:Name="HeaderPanel"
                            Panel.ZIndex ="1" 
                            KeyboardNavigation.TabIndex="1"
                            Grid.Column="0"
                            Grid.Row="0"
                            Margin="2,2,2,0"
                            IsItemsHost="true"  />
                        <Border 
                            x:Name="ContentPanel"
                            Background="{TemplateBinding Background}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            KeyboardNavigation.TabNavigation="Local"
                            KeyboardNavigation.DirectionalNavigation="Contained"
                            KeyboardNavigation.TabIndex="2"
                            Grid.Column="0"
                            Grid.Row="1">
                            <ContentPresenter 
                                x:Name="PART_SelectedContentHost"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                Margin="{TemplateBinding Padding}"
                                ContentSource="SelectedContent"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement"
                                 Value="Bottom">
                            <Setter Property="Grid.Row"
                                    Value="1"
                                    TargetName="HeaderPanel"/>
                            <Setter Property="Grid.Row"
                                    Value="0"
                                    TargetName="ContentPanel"/>
                            <Setter Property="Height"
                                    Value="*"
                                    TargetName="RowDefinition0"/>
                            <Setter Property="Height"
                                    Value="Auto"
                                    TargetName="RowDefinition1"/>
                            <Setter Property="Margin"
                                    Value="2,0,2,2"
                                    TargetName="HeaderPanel"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement"
                                 Value="Left">
                            <Setter Property="Grid.Row"
                                    Value="0"
                                    TargetName="HeaderPanel"/>
                            <Setter Property="Grid.Row"
                                    Value="0"
                                    TargetName="ContentPanel"/>
                            <Setter Property="Grid.Column"
                                    Value="0"
                                    TargetName="HeaderPanel"/>
                            <Setter Property="Grid.Column"
                                    Value="1"
                                    TargetName="ContentPanel"/>
                            <Setter Property="Width"
                                    Value="Auto"
                                    TargetName="ColumnDefinition0"/>
                            <Setter Property="Width"
                                    Value="*"
                                    TargetName="ColumnDefinition1"/>
                            <Setter Property="Height"
                                    Value="*"
                                    TargetName="RowDefinition0"/>
                            <Setter Property="Height"
                                    Value="0"
                                    TargetName="RowDefinition1"/>
                            <Setter Property="Margin"
                                    Value="2,2,0,2"
                                    TargetName="HeaderPanel"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement"
                                 Value="Right">
                            <Setter Property="Grid.Row"
                                    Value="0"
                                    TargetName="HeaderPanel"/>
                            <Setter Property="Grid.Row"
                                    Value="0"
                                    TargetName="ContentPanel"/>
                            <Setter Property="Grid.Column"
                                    Value="1"
                                    TargetName="HeaderPanel"/>
                            <Setter Property="Grid.Column"
                                    Value="0"
                                    TargetName="ContentPanel"/>
                            <Setter Property="Width"
                                    Value="*"
                                    TargetName="ColumnDefinition0"/>
                            <Setter Property="Width"
                                    Value="Auto"
                                    TargetName="ColumnDefinition1"/>
                            <Setter Property="Height"
                                    Value="*"
                                    TargetName="RowDefinition0"/>
                            <Setter Property="Height"
                                    Value="0"
                                    TargetName="RowDefinition1"/>
                            <Setter Property="Margin"
                                    Value="0,2,2,2"
                                    TargetName="HeaderPanel"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" 
                                 Value="false">
                            <Setter Property="Foreground" 
                                    Value="{StaticResource DisabledForegroundBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style 
        x:Key="HeaderTabItemStyle" 
        TargetType="{x:Type TabItem}">
        <Setter Property="FocusVisualStyle" 
                Value="{x:Null}" />
        <Setter Property="IsTabStop"
                Value="False" />
        <Setter Property="BorderThickness" 
                Value="1" />
        <Setter Property="Padding" 
                Value="6,2,6,2" />
        <Setter Property="HorizontalContentAlignment" 
                Value="Stretch" />
        <Setter Property="VerticalContentAlignment" 
                Value="Stretch" />
        <Setter Property="MinWidth" 
                Value="5" />
        <Setter Property="MinHeight" 
                Value="5" />
        <Setter Property="FontFamily" 
                Value="{StaticResource MainFontFamily}" />
        <Setter Property="Background" 
                Value="{StaticResource MainColorBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TabItem">
                    <Label 
                        x:Name="root" 
                        FontSize="{StaticResource LargeFontSize}" >
                        <ContentPresenter ContentSource="Header" 
                                          RecognizesAccessKey="True" />
                    </Label>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" 
                                 Value="true">
                            <Setter TargetName="root" 
                                    Property="Foreground" 
                                    Value="{StaticResource DarkForegroundBrush}" />
                        </Trigger>

                        <Trigger Property="IsSelected" 
                                 Value="false">
                            <Setter  TargetName="root" 
                                     Property="Foreground" 
                                     Value="{StaticResource DisabledForegroundBrush}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition SourceName="root" 
                                           Property="IsMouseOver" 
                                           Value="True" />
                                <Condition Property="IsSelected" 
                                           Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter  TargetName="root" 
                                     Property="Foreground" 
                                     Value="{StaticResource DarkForegroundBrush}" />
                        </MultiTrigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Main Window Style -->
    <Style x:Key="{x:Type views:MainWindow}" 
           TargetType="{x:Type views:MainWindow}">

        <Setter Property="shell:WindowChrome.WindowChrome">
            <Setter.Value>
                <shell:WindowChrome
                    ResizeBorderThickness="6"
                    CaptionHeight="12"
                    CornerRadius="0"
                    GlassFrameThickness="0,0,0,1"/>
            </Setter.Value>
        </Setter>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Window}">
                    <Grid 
                        x:Name="LayoutRootGrid" 
                        Background="{StaticResource MainColorBrush}">

                        <Grid.RowDefinitions>
                            <RowDefinition Height="30" />
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                        <Border 
                            x:Name="MainBorder" 
                            Grid.Row="0" 
                            Grid.RowSpan="2" 
                            BorderThickness="1" 
                            BorderBrush="{StaticResource DisabledForegroundBrush}" />

                        <Grid 
                            x:Name="TitleLayoutGrid" 
                            Grid.Row="0">

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <TextBlock 
                                x:Name="TitleText" 
                                Grid.Column="0"  
                                Grid.ColumnSpan="3"
                                VerticalAlignment="Stretch"
                                HorizontalAlignment="Stretch">
                            </TextBlock>

                            <StackPanel 
                                x:Name="ButtonPanel" 
                                Grid.Column="2" 
                                Margin="2, 2, 6, 2"
                                Orientation="Horizontal">
                                <Button 
                                    x:Name="PART_MinimizeButton"
                                    Style="{StaticResource ChromeButtonStyle}"
                                    shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                    IsTabStop="False"
                                    Width="18"
                                    MaxHeight="18"
                                    Padding="0" 
                                    ToolTip="Minimize">
                                    <Grid Margin="0, 7, 0, 0">
                                        <Path 
                                            Height="12"
                                            Width="9"
                                            Stretch="UniformToFill" 
                                            StrokeThickness="1"
                                            Stroke="{StaticResource DarkForegroundBrush}"
                                            Data="{StaticResource MinimizeIconGeometry}" />
                                    </Grid>
                                </Button>

                                <Button 
                                    x:Name="PART_MaximizeButton"
                                    Style="{StaticResource ChromeButtonStyle}"
                                    shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                    IsTabStop="False"
                                    Width="18"
                                    MaxHeight="18"
                                    Padding="0"
                                    ToolTip="Maximize">
                                    <Grid>
                                        <Path 
                                            x:Name="PART_MaximizePath"
                                            Height="8"
                                            Width="8"
                                            Stretch="Uniform" 
                                            StrokeThickness="1"
                                            Stroke="{StaticResource DarkForegroundBrush}" 
                                            Data="{StaticResource MaximizeIconGeometry}" 
                                            Visibility="Visible" />
                                        <Path x:Name="PART_RestorePath"
                                              Height="10"
                                              Width="10"
                                              Stretch="Uniform" 
                                              StrokeThickness="1"
                                              Stroke="{StaticResource DarkForegroundBrush}" 
                                              Data="{StaticResource RestoreIconGeometry}" 
                                              Visibility="Collapsed" />
                                    </Grid>
                                </Button>

                                <Button 
                                    x:Name="PART_CloseButton"
                                    Style="{StaticResource ChromeButtonStyle}"
                                    shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                    IsTabStop="False"
                                    Width="18"
                                    MaxHeight="18"
                                    Padding="0" 
                                    ToolTip="Close">
                                    <Grid>
                                        <Path 
                                            Height="8"
                                            Width="8"
                                            Stretch="Uniform" 
                                            StrokeThickness="1"
                                            Stroke="{StaticResource DarkForegroundBrush}" 
                                            Data="{StaticResource CloseIconGeometry}" />
                                    </Grid>
                                </Button>
                            </StackPanel>
                        </Grid>

                        <ContentPresenter 
                            x:Name="MainContentPresenter" 
                            Margin="6" 
                            Grid.Row="1" 
                            Content="{TemplateBinding Content}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>